package javacafe.action.study;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.service.StudyService;
import javacafe.serviceimple.StudyServiceImpl;

public class AuthMgrAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		ActionForward forward = new ActionForward();
		int study_no = Integer.parseInt(request.getParameter("study_no"));
		forward.setTiles(false);
		forward.setRedirect(true);
		forward.setUrl("study?command=authmgr&study_no=" + study_no );
		
		String[] arrym_no = request.getParameterValues("m_no");
		int[] m_no = new int[arrym_no.length];
		for (int i = 0; i < m_no.length; i++) {
			m_no[i] = Integer.parseInt( arrym_no[i] );
		}
		
		String sauth_name = request.getParameter("sauth_name");
		
		StudyService studyService = StudyServiceImpl.getInstance();
		studyService.updateAuth(sauth_name, m_no);

		return forward;
	}

}
